package com.temperate;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * @author:wesley
 */
public class TempGroup extends WritableComparator{


    public TempGroup() {
        super(TempKey.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {

        TempKey k1 = (TempKey) a;
        TempKey k2 = (TempKey) b;

        int r1 = Integer.compare(k1.getYear(), k2.getYear());
        if (r1 == 0) {
            return Integer.compare(k1.getMonth(), k2.getMonth());
        } else {
            return r1;
        }
    }


}
